import { DatabaseModule } from '@app/database';
import { UtilsModule } from '@app/utils';
import { Global, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { MulterModule } from '@nestjs/platform-express';
import { ServeStaticModule } from '@nestjs/serve-static';
import { JwtStrategy } from './jwt.strategy';

@Global()
@Module({
  imports: [
    MulterModule.register({
      dest: 'static/uploads',
    }),
    ConfigModule.forRoot({
      isGlobal: true,
    }),
    ServeStaticModule.forRoot({
      rootPath: 'static',
    }),
    JwtModule.register({
      secret: process.env.SECRET,
      signOptions: {
        expiresIn: '24h',
      },
    }),
    DatabaseModule,
    UtilsModule,
  ],
  providers: [JwtStrategy],
  exports: [DatabaseModule, UtilsModule, MulterModule, ConfigModule, JwtModule],
})
export class CommonModule {}
